/**
 * 岗位service
 * @author 李艳
 */
import httpUtils  from "../../../commons/utils/FeatchUtils";
import {basicUrl} from "../../../configs/DefaultConfig"
import {convertDataToFormData} from "../../../commons/utils/CommonUtils";

/**
 * 获得组织机构下所有岗位
 *
 * param organizationId 组织机构ID
 */
export async function findByOrganizationId(params={}){
    Object.assign(params, {S_code: 'asc'});
    return httpUtils.get(basicUrl+"/position/findByOrganizationId",params);
}

export async function savePosition(params={}){
    return httpUtils.postJson(basicUrl+"/position/save",params);
}

export async function deletePosition(param=""){
    return httpUtils.delete(basicUrl+"/position/delete",param);
}
//假分页
export async function listAllCanAssignEmployees(params={}){
 // return httpUtils.postJson(basicUrl+"/employee/listAllCanAssignEmployees"+`/${positionId}`,params,false,true);
  return httpUtils.postJson(basicUrl+"/employee/listAllCanAssignEmployees",params);
}
export async function listAllAssignedEmployeesByPositionId(params={}){
    return httpUtils.get(basicUrl+"/employeePosition/listAllAssignedEmployeesByPositionId",params);
}

export async function listAllCanAssignFeatureRolesByPosition(params=""){
    return httpUtils.get(basicUrl+"/positionFeatureRole/getUnassigned",params);
}

export async function listAllAssignedFeatureRolesByPosition(params=""){
    return httpUtils.get(basicUrl+"/positionFeatureRole/getChildrenFromParentId",params);
}
export async function removeEmployeePositionDto(params={}){
  return httpUtils.delete(basicUrl+"/employeePosition/removeRelationsByParentsDto",JSON.stringify(params));
}
export async function insertEmployeePositionDto(params={}){
  return httpUtils.postJson(basicUrl+"/employeePosition/insertRelationsByParentsDto",JSON.stringify(params));
}

/**
 * 功能角色组
 * @param params
 * @returns {Promise<*>}
 */
export async function listAllFeatureRoleGroup(params = {}) {
    return httpUtils.get(basicUrl + "/featureRoleGroup/findAll", params);
}
/**
 * 根据positionId，featureRoleGroupId获得所有功能角色
 *
 * param positionId，featureRoleGroupId
 */
export async function listAllCanAssignFeatureRolesByPositionAndRoleGroup(params={}){
    return httpUtils.get(basicUrl+"/position/getCanAssignedFeatureRoles",params);
}
export async function removeFeatureRoles(params={}){
    return httpUtils.delete(basicUrl+"/positionFeatureRole/removeRelationsByParam",JSON.stringify(params));
}
export async function insertFeatureRoles(params={}){
    return httpUtils.postJson(basicUrl+"/positionFeatureRole/insertRelationsByParam",JSON.stringify(params));
}


/**
 * 获得所有数据角色
 *
 * param positionId
 */
export async function listAllCanAssignDataRolesByPosition(params=""){
    return httpUtils.get(basicUrl+"/positionDataRole/getUnassigned",params);
}
/**
 * 获得已分配数据角色
 *
 * param parentId
 */
export async function listAllAssignedDataRolesByPosition(params=""){
    return httpUtils.get(basicUrl+"/positionDataRole/getChildrenFromParentId",params);
}

/**
 * 数据角色组
 * @param params
 * @returns {Promise<*>}
 */
export async function listAllDataRoleGroup(params = {}) {
    return httpUtils.get(basicUrl + "/dataRoleGroup/findAll", params);
}

/**
 * 根据positionId，dataRoleGroupId获得所有数据角色
 *
 * param
 */
export async function listAllCanAssignDataRolesByPositionAndRoleGroup(params={}){
    return httpUtils.get(basicUrl+"/position/getCanAssignedDataRoles",params);
}
export async function removeDataRoles(params={}){
    return httpUtils.delete(basicUrl+"/positionDataRole/removeRelationsByParam",JSON.stringify(params));
}
export async function insertDataRoles(params={}){
    return httpUtils.postJson(basicUrl+"/positionDataRole/insertRelationsByParam",JSON.stringify(params));
}

